<?php
require_once __DIR__.'/ProductCRUDController.class.php';
require_once __DIR__.'/CategoryCRUDController.class.php';
require_once __DIR__.'/CustomerCRUDController.class.php';
require_once __DIR__.'/OrderCRUDController.class.php';

Class Controller 
{
	static $cntlr = array(
		"product-list" => array ( "template" => "product/list.html"),
		"product-edit" => array ( "template" => "product/edit.html"),
		"product-add" => array ( "template" => "product/add.html"),
		"product-save" => array ( "controller" => "ProductCRUDController" ,"method" => "save","template" => "product/edit.html"),
		"product-delete" => array ( "controller" => "ProductCRUDController" ,"method" => "delete","template" => "product/list.html"),
		"product-offline" => array ( "controller" => "ProductCRUDController" ,"method" => "offline","template" => "product/list.html"),
		"product-online" => array ( "controller" => "ProductCRUDController" ,"method" => "online","template" => "product/list.html"),
                "product-copy" => array ( "controller" => "ProductCRUDController" ,"method" => "copy","template" => "product/list.html"),
		"product_attribute-edit" => array ( "template" => "product/attribute/edit.html"),
		"product_attribute-save" => array ( "controller" => "ProductCRUDController" ,"method" => "attribute_save","template" => "product/attribute/edit.html"),
		"product_attribute_ca-save" => array ( "controller" => "ProductCRUDController" ,"method" => "attribute_ca_save","template" => "product/attribute/edit.html"),
		"product_attribute_ca-delete" => array ( "controller" => "ProductCRUDController" ,"method" => "attribute_ca_delete","template" => "product/attribute/edit.html"),
		"product_images-edit" => array ( "template" => "product/images/edit.html"),
		"product_images-save" => array ( "controller" => "ProductCRUDController" ,"method" => "images_save","template" => "product/images/edit.html"),
		"product_images-delete" => array ( "controller" => "ProductCRUDController" ,"method" => "images_delete","template" => "product/images/edit.html"),
		"product_pricing-edit" => array ( "template" => "product/pricing/edit.html"),
		"product_pricing-save" => array ( "controller" => "ProductCRUDController" ,"method" => "prices_save","template" => "product/pricing/edit.html"),
		"product_pricing-delete" => array ( "controller" => "ProductCRUDController" ,"method" => "prices_delete","template" => "product/pricing/edit.html"),
		"product_promotions-edit" => array ( "template" => "product/promotions/edit.html"),
		"product_promotions-save" => array ( "controller" => "ProductCRUDController" ,"method" => "promotions_save","template" => "product/promotions/edit.html"),
		"product_promotions-delete" => array ( "controller" => "ProductCRUDController" ,"method" => "promotions_delete","template" => "product/promotions/edit.html"),
		
		"product_categories-edit" => array ( "template" => "product/categories/edit.html"),
		"product_categories-save" => array ( "controller" => "ProductCRUDController" ,"method" => "categories_save","template" => "product/categories/edit.html"),
		"product_variations-edit" => array ( "template" =>"product/variations/edit.html"),
		"product_variations-add" => array ( "controller" => "ProductCRUDController" ,"method" => "variations_add","template" => "product/variations/edit.html"),
		
		"category-list" => array ("template" => "category/list.html"),
		"category-edit" => array ("template" => "category/edit.html"),
		"category-add" => array ("template" => "category/add.html"),
		"category-save" => array ( "controller" => "CategoryCRUDController" ,"method" => "save","template" => "category/edit.html"),
		"category-delete" => array ( "controller" => "CategoryCRUDController" ,"method" => "delete","template" => "category/list.html"),
		"category_product-list" => array ("template" => "category/product/list.html"),
		
		"customer-list" => array ("template" => "customer/list.html"),
                "customer-edit" => array ( "template" => "customer/edit.html"),
                "customer-add" => array ("template" => "customer/add.html"),
                "customer-save" => array ( "controller" => "CustomerCRUDController" ,"method" => "save","template" => "customer/edit.html"),
                "customer_order-list" => array ( "template" => "customer/order/list.html"),
                
                "order-list" => array ("template" => "order/list.html"),
                "order-edit" => array ("template" => "order/edit.html"),
                "order-status" =>  array ( "controller" => "OrderCRUDController" ,"method" => "status","template" => "order/list.html"),
	);

	static function execute($target)
	{	
		$temp=null;
		if(isset(self::$cntlr[$target]))
		{		
			$arry=self::$cntlr[$target];			
			if(!empty($arry))
			{
				if(isset($arry["controller"]) && isset($arry["method"]))
				{				
					$controller= $arry["controller"];
					$method= $arry["method"];
					$cntlrInstance = new $controller();
					$cntlrInstance->$method();
				}
				$temp= $arry["template"];					
			}
		}
		return $temp;
		
	}
}
